<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()
const searchQuery = ref('')

const handleSearch = () => {
  if (searchQuery.value.trim()) {
    router.push({
      name: 'Search',
      query: {q: searchQuery.value.trim()}
    })
    // 清除搜索框内容
    searchQuery.value = ''
  }
}

// 处理回车键搜索
const handleKeyPress = (event) => {
  if (event.key === 'Enter') {
    handleSearch()
  }
}
</script>

<template>
  <div class="app-box">
    <div class="app-box-content">
      <!-- 1. 导航栏（固定高度） -->
      <div v-if="!$route.meta.hideNavbar" class="app-header">
        <div class="app-header-logo">
          <h1>叶境</h1>
          <span> -免费壁纸分享平台</span>
        </div>
        <div class="app-header-nav-menu">
          <router-link to="/" class="nav-link" :class="{ 'active': $route.path === '/' }">首页</router-link>
          <router-link to="/hottest-ranking" class="nav-link" :class="{ 'active': $route.path === '/hottest-ranking' }">最热排行</router-link>
          <router-link to="/classification-query" class="nav-link" :class="{ 'active': $route.path === '/classification-query' }">分类查询</router-link>
          <router-link to="/search" class="nav-link" :class="{ 'active': $route.path === '/search' }">搜索</router-link>
          <router-link to="/about" class="nav-link" :class="{ 'active': $route.path === '/about' }">关于</router-link>
        </div>
        <div class="app-header-search">
          <div class="app-header-search-one">
            <div class="search-input-wrapper">
              <input v-model="searchQuery" @keyup.enter="handleSearch" @keypress="handleKeyPress" type="text" placeholder="关键字搜索壁纸..."
                     class="search-input">
            </div>
          </div>
          <router-link to="/visitorLogin" class="app-header-search-two">
            <h2>登录</h2>
          </router-link>
        </div>
      </div>
      <!-- 2. 主内容区域（自适应） -->
      <div class="app-content">
        <router-view/>
      </div>
      <!-- 3. 尾部介绍 -->
      <div v-if="!$route.meta.hideNavbar" class="app-footer">
        <p>
          本站发布的图片均来自互联网和用户分享，本站图片仅供学习，参考，交流使用，禁止用作商业用途。由此引起的任何后果自行承担，与本站无关!</p>
        <p>如果侵害了您的正常权益，请发邮件至 foliage2025@yeah.net 与我们联系，我们将及时处理。</p>
        <p> Copyright ©2025 - 叶境. 保留所有权利。| 叶境 - 免费高清壁纸下载平台</p>
      </div>
    </div>
  </div>
</template>

<style scoped lang="less">
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.app-box {
  width: 100%;
  height: 100vh;
  background-image: url("https://res.volccdn.com/obj/volc-console-fe/vconsole-static/auth.coze-bg-20250529.f88b4dc9.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  flex-direction: column;


  /*1. 导航栏（固定高度）*/

  .app-header {
    height: 60px;
    background-color: #444;
    display: flex;
    align-items: center;
    color: #f8f9fa; // 接近白色但更柔和

    .app-header-logo {
      margin-left: 30px;
      padding: 10px 20px 10px 0;
      display: flex;
      align-items: center;

      svg {
        width: 40px;
        height: 40px;
        margin-right: 10px;
      }

      h1 {
        color: #ffffff; // 标题使用纯白
        margin: 0;
        padding: 0;
        font-size: 28px;
      }

      span {
        color: #e6f3ff; // 描述文字使用淡蓝白
        font-size: 16px;
        margin-left: 5px;
        margin-top: 8px;
      }
    }

    .app-header-nav-menu {
      padding-left: 25px;
      display: flex;
      gap: 2.5rem;
      align-items: center;

      .nav-link {
        text-decoration: none;
        color: #f8f9fa;
        font-size: 18px;
        position: relative;
        padding: 8px 0;

        // 添加悬停效果
        &:hover {
          color: #333;
        }

        // 激活状态样式
        &.active {
          color: #3cb450;
          font-weight: 600;

          &::after {
            content: '';
            position: absolute;
            bottom: -2px;
            left: 0;
            width: 100%;
            height: 3px;
            background: linear-gradient(90deg, #3cb450, #2ecc71);
            border-radius: 2px;
            animation: slideIn 0.3s ease;
          }
        }
      }

      @keyframes slideIn {
        from {
          width: 0;
          opacity: 0;
        }
        to {
          width: 100%;
          opacity: 1;
        }
      }
    }

    .app-header-search {
      padding-right: 30px;
      margin-left: auto;
      display: flex;
      align-items: center;

      .app-header-search-one {
        position: relative;
        display: flex;
        align-items: center;

        .search-input-wrapper {
          position: relative;
          display: flex;
          align-items: center;

          .search-input {
            padding: 8px 12px 8px 32px; // 左侧留出图标空间
            border: 1px solid #e2e8f0;
            border-radius: 6px;
            font-size: 14px;
            width: 200px;

            // 添加焦点样式
            &:focus {
              outline: none;
              border-color: #409eff;
              box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
            }
          }

          .search-icon {
            position: absolute;
            left: 8px;
            width: 16px;
            height: 16px;
            pointer-events: none; // 图标不响应点击事件
          }
        }
      }

      .app-header-search-two {
        margin-left: 20px;
        display: flex;
        align-items: center;
        background-color: #3cb450; // 添加背景色
        padding: 2px 10px; // 添加内边距使背景更明显
        border-radius: 5px; // 添加圆角
        cursor: pointer; // 添加鼠标指针样式
        transition: background-color 0.3s; // 添加过渡效果
        text-decoration: none;

        &:hover {
          background-color: #333; // 悬停时加深颜色
        }

        h2 {
          font-size: 18px;
          font-weight: 400;
          color: white;
          margin: 0;
        }
      }
    }
  }

  /*2. 主内容区域（自适应*/

  .app-content {
    flex: 1;

    .app-content-illustrate {
      height: 250px; /* 减少高度 */
      position: relative; /* 添加相对定位 */
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      overflow: hidden; /* 确保视频不会溢出容器 */

      .video-background {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        overflow: hidden;
        z-index: 0; /* 调整z-index */

        .background-video {
          position: absolute;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
          object-fit: cover; /* 确保视频覆盖整个容器 */
          z-index: 0; /* 调整z-index */
          min-width: 100%;
          min-height: 100%;
        }

        .fallback-background {
          position: absolute;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
          background-image: url("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1200&h=400&fit=crop");
          background-size: cover;
          background-position: center;
          background-repeat: no-repeat;
          z-index: -1; /* 在视频后面作为备用 */
          opacity: 0.8;
        }
      }

      .content-overlay {
        background: rgba(0, 0, 0, 0.3);
        backdrop-filter: blur(2px);
        padding: 20px;
        border-radius: 10px;
        text-align: center;
        z-index: 10; /* 确保在视频之上 */
        position: relative; /* 添加相对定位 */

        p {
          color: white;
          text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
          font-size: 18px;
          line-height: 1.8;
        }
      }
    }

    .app-content-dynamic-images {
      padding: 30px 20px;
      background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
      border-radius: 12px;
      margin: 0 30px 20px;
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);

      /*精选壁纸*/
      .section-title {
        font-size: 28px;
        font-weight: 600;
        margin-bottom: 40px;
        text-align: center;
        color: #2c3e50;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;

        svg {
          width: 50px;
          height: 50px;
          position: absolute;
          left: calc(50% + 70px); /* 根据需要调整偏移量 */
          top: 50%;
          transform: translateY(-50%) translateY(3px);
          border: none; /* 默认情况下没有边框 */

          /* 鼠标悬停时的效果 */
          &:hover {
            transform: translateY(-50%) translateY(3px) scale(1.1); /* 放大 svg */
            fill: #3cb450; /* 改变填充颜色 */
            cursor: pointer; /* 更改鼠标指针样式 */
          }
        }


        &::after {
          content: '';
          position: absolute;
          bottom: -8px;
          left: 50%;
          transform: translateX(-50%);
          width: 60px;
          height: 3px;
          background: linear-gradient(90deg, #3498db, #2ecc71);
          border-radius: 2px;
        }
      }

      .image-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
        max-width: 1250px;
        margin: 0 auto;
      }

      .image-card {
        width: 100%;
        aspect-ratio: 4/3;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
        cursor: pointer;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        position: relative;

        &:hover {
          transform: translateY(-8px) scale(1.02);
          box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
        }

        .image-wrapper {
          position: relative;
          width: 100%;
          height: 100%;
          overflow: hidden;

          .grid-image {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.3s ease;
          }

          .image-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.4) 100%);
            display: flex;
            justify-content: center;
            align-items: center;
            opacity: 0;
            transition: all 0.3s ease;
            color: white;
            text-align: center;
            padding: 20px;
          }

          &:hover {
            .image-overlay {
              opacity: 1;
            }

            .grid-image {
              transform: scale(1.1);
            }
          }
        }

        .overlay-content {
          h4 {
            font-size: 20px;
            margin-bottom: 8px;
            font-weight: 600;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
          }

          p {
            font-size: 14px;
            color: #e8e8e8;
            line-height: 1.4;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
          }
        }
      }
    }

    /*热门标签*/
    .app-content-Hot-Tags {
      padding: 20px 20px;
      background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
      border-radius: 12px;
      margin: 0 30px 20px;
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);

      .hot-tags-header {
        font-size: 28px;
        font-weight: 600;
        margin-bottom: 40px;
        text-align: center;
        color: #2c3e50;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;

        .section-title {
          font-size: 28px;
          font-weight: 600;
          text-align: center;
          color: #2c3e50;
          position: relative;
          display: flex;
          align-items: center;
          justify-content: center;

          svg {
            width: 50px;
            height: 50px;
            position: absolute;
            left: calc(50% + 70px); /* 根据需要调整偏移量 */
            top: 50%;
            transform: translateY(-50%) translateY(3px);
            border: none; /* 默认情况下没有边框 */

            /* 鼠标悬停时的效果 */
            &:hover {
              transform: translateY(-50%) translateY(3px) scale(1.1); /* 放大 svg */
              fill: #3cb450; /* 改变填充颜色 */
              cursor: pointer; /* 更改鼠标指针样式 */
            }
          }


          &::after {
            content: '';
            position: absolute;
            bottom: -8px;
            left: 50%;
            transform: translateX(-50%);
            width: 60px;
            height: 3px;
            background: linear-gradient(90deg, #3498db, #2ecc71);
            border-radius: 2px;
          }
        }
      }

      /*标签的具体内容*/
      .app-content-Hot-Tags-box{
        height: 200px;
        margin: 5px 60px;
        border: 2px dashed #ccc;
      }

      // 标签网格样式
      .tags-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 12px;
        padding: 20px;
        height: 100%;
        overflow-y: auto;

        .tag-item {
          display: flex;
          align-items: center;
          gap: 6px;
          background: rgba(255, 255, 255, 0.15);
          color: #2c3e50;
          padding: 10px 12px;
          border-radius: 8px;
          font-size: 13px;
          font-weight: 500;
          cursor: pointer;
          transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
          border: 1px solid rgba(255, 255, 255, 0.2);
          backdrop-filter: blur(5px);
          position: relative;
          overflow: hidden;
          text-align: center;
          justify-content: center;
          box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);

          &::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
            transition: left 0.5s ease;
          }

          &:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: translateY(-2px) scale(1.02);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
            border-color: rgba(255, 255, 255, 0.4);
            color: #1a202c;

            &::before {
              left: 100%;
            }
          }

          &:active {
            transform: translateY(0) scale(0.98);
          }

          .tag-icon {
            width: 14px;
            height: 14px;
            flex-shrink: 0;
            color: #3cb450;
          }
        }

        @media (max-width: 768px) {
          grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
          gap: 10px;
          padding: 15px;

          .tag-item {
            padding: 8px 10px;
            font-size: 12px;

            .tag-icon {
              width: 12px;
              height: 12px;
            }
          }
        }
      }
    }

  }

  /*3. 尾部介绍*/
  .app-footer {
    height: 100px;
    background-color: #444;
    display: flex;
    flex-direction: column;
    justify-content: center; /* 垂直居中 */
    align-items: center; /* 水平居中 */
    color: #aaa;
    font-size: 14px;
    padding: 20px; /* 添加内边距以防止内容贴边 */

    p {
      text-align: center; /* 文本居中 */
      line-height: 1.6; /* 增加行高提高可读性 */
    }
  }
}

</style>
